// 提示弹框
export function toast(text) {
	uni.showToast({
		title: text,
		icon:'none',
		duration: 2000
	});
}
export function getDayStatus(item,type) {
	let Morning = ''
	let Afternoo = ''
	let Night = ''
	if (type == 1) {
		Morning = item.saturdayMorning
		Afternoo = item.saturdayAfternoon
		Night = item.saturdayNight
	} else {
		Morning = item.sundayMorning
		Afternoo = item.sundayAfternoon
		Night = item.sundayNight
	}
	if (Morning==1&&Afternoo==1&&Night==1) {
		return '全天'
	} else if (Morning==1) {
		return '上午'
	} else if (Afternoo==1) {
		return '下午'
	} else if (Night==1) {
		return '晚上'
	} else {
		return ''
	}
}
// 根据时间戳获取年月日
export function getDate(time) {
	var timestr = new Date(parseInt(time) * 1000)
	var year = timestr.getFullYear();
	var month = addZero(timestr.getMonth()+1)
	var date = addZero(timestr.getDate())
	var hour = addZero(timestr.getHours())
	var minute = addZero(timestr.getMinutes())
	var second = addZero(timestr.getSeconds())
	return `${year}-${month}-${date} ${hour}:${minute}:${second}`
}

// 根据时间戳获取时间
export function getDays(time) {
	console.log(time)
	time = time / 1000
	let day = Math.floor(time / 24 / 3600)
	let hour = Math.floor((time - day * 24 * 3600) / 3600)
	let minute = Math.floor((time - day * 24 * 3600 - hour * 3600) / 60)
	let second = time - day * 24 * 3600 - hour * 3600 - minute * 60
	hour = addZero(hour)
	minute = addZero(minute)
	second = addZero(second)
	return `${day}天${hour}时${minute}分${second}秒` 
}
// 数字前加0
function addZero(t) {
	return t > 9 ? t : '0' + t
}

// 检测手机号格式
export function checkTel(tel) {
	return /^1\d{10}$/.test(tel)
}